/*
 * @Author: hyq
 * @LastEditors: hyq
 * @Description:debounce
 * @Date: 2023-12-05 11:00:33
 */
export default function debounce(fn: any, delay: number) {
  let timer: number | undefined
  return function (this: any, ...args: any[]) {
    !!timer ? clearTimeout(timer) : fn.apply(this, args)
    timer = setTimeout(() => {
      timer = undefined
    }, delay)
  }
}
